﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;

namespace SeleniumToolkit.Config
{
    /// <summary>
    /// Configuration element for the Selenium Addin
    /// </summary>
    public class SeleniumConfigurationAddinElement : ConfigurationElement
    {
        static SeleniumConfigurationAddinElement()
        {
            PropertyCollection = new ConfigurationPropertyCollection();

            RecylePerFixtureProperty = new ConfigurationProperty(RecylePerFixtureKey, typeof(bool), RecylePerFixtureDefault);
            PropertyCollection.Add(RecylePerFixtureProperty);
        }

        /// <summary>
        /// Gets the collection of ConfigurationProperties
        /// </summary>
        protected override ConfigurationPropertyCollection Properties
        {
            get
            {
                return PropertyCollection;
            }
        }

        /// <summary>
        /// Flag to determine if the addin should recyle the browser for each fixture.  When false, the browser is recyled per test.
        /// </summary>
        [ConfigurationProperty(RecylePerFixtureKey, DefaultValue = RecylePerFixtureDefault)]
        public bool RecylePerFixture
        {
            get { return (bool)base[RecylePerFixtureProperty]; }
            set { base[RecylePerFixtureProperty] = value; }
        }

        private static readonly ConfigurationPropertyCollection PropertyCollection;

        private static readonly ConfigurationProperty RecylePerFixtureProperty;
        private const string RecylePerFixtureKey = "recylePerFixture";
        private const bool RecylePerFixtureDefault = true;
    }
}
